#!/bin/bash
role=$1
mode=$(cat mode)
echo "$(date +"%Y-%m-%d %H:%M:%S") INFO stopping $role in $mode mode"
function stop_jobmanager(){
    jobmanager.sh stop
}

function stop_taskmanager(){
    taskmanager.sh stop
}

if [ $role == "jobmanager" ];then
	stop_jobmanager
fi

if [ $role == "taskmanager" ];then
	stop_taskmanager
fi


if [ $role == "all" ];then
	if [ $mode == "ha" ];then
		echo "$(date +"%Y-%m-%d %H:%M:%S") WARNING parameter all is only supported in sa mode"
		exit 1
	fi
	stop_jobmanager
	stop_taskmanager
fi